<?php

/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

/**
 * Description of wallet
 *
 * @author win7
 */
class userswallet extends admin_controller {

    //put your code here
    public function __construct() {
        parent::__construct();
        $this->load->model('admin/wallet_model', 'wallete');
    }

    public function index($offset = false) {
        $limit = metohd_get_uri('dblimit', ADMIN_LIMIT);
        $count = $this->wallete->filter(true);
        $this->pass['count'] = $count;
        $this->pass['limit'] = $limit;
        $this->pass['result'] = $this->wallete->filter(FALSE, $offset);
        $this->pass['pagination'] = $this->admin_pagination('index', $count, $limit);
        $this->themes->render('wallet/index', $this->pass);
    }

    public function confirm($id = FALSE) {
        $falid_id = $this->wallete->is_found(array('wallet.id' => $id), array(), 'row', $this->agent->referrer());
        $this->wallete->confirm($falid_id);
        $this->themes->set_message(array('url' => $this->agent->referrer(), 'type' => 'success', 'message' => 'message_confirm_success'));
    }

    public function rejected($id = FALSE) {
        $falid_id = $this->wallete->is_found(array('wallet.id' => $id), array(), 'row', $this->agent->referrer());
        $this->wallete->rejected($falid_id->id);
        $this->themes->set_message(array('url' => $this->agent->referrer(), 'type' => 'success', 'message' => 'message_operation_success'));
    }

    public function view($id = FALSE) {
        $falid_id = $this->wallete->is_found(array('wallet.id' => $id), array(), 'row', $this->agent->referrer());
        $data['result'] = $falid_id;
        $this->themes->render('wallet/view', $data);
    }

    public function all() {
        $id = $this->input->post('id');
        $doaction = $this->input->post('doaction');
        $this->empty_id_actionall($id);
        $this->empty_id_actionall($doaction, 'message_select_action_from_dropdown');
        switch ($doaction) {
            case 'rejected': {
                    $this->wallete->rejected($id);
                    $this->themes->set_message(array('url' => $this->agent->referrer(), 'type' => 'success', 'message' => 'message_edit_success'));
                }
                break;
            case 'delete': {
                    $this->wallete->delete(array('id' => $id), FALSE);
                    $this->themes->set_message(array('url' => $this->agent->referrer(), 'type' => 'success', 'message' => 'message_edit_success'));
                }
                break;
            default:
                redirect($this->agent->referrer());
                break;
        }
        //  echo json_encode($_POST['manager']);
    }

    public function delete($id = FALSE) {
        if($id){
            $falid_id = $this->wallete->is_found(array('wallet.id' => $id), array(), 'row', $this->agent->referrer());
            if($this->wallete->delete(array('id' => $id), FALSE)){
                $this->themes->set_message(array('url' => $this->agent->referrer(), 'type' => 'success', 'message' => 'message_delete_success'));
            }else{
                $this->themes->set_message(array('url' => $this->agent->referrer(), 'type' => 'error', 'message' => 'message_delete_error'));
            }
        }else{
            show_404();
        }
        
        
    }

}

?>
